import tkinter as tk
from .gui.main_window import MainWindow
from app.config.manager import ConfigManager
from app.core.plugin import PluginManager
from app.services.updater import AutoUpdater

def main():
    root = tk.Tk()
    root.geometry("1200x800")

    # 初始化核心组件
    config = ConfigManager()
    plugin_manager = PluginManager()

    # 发现并加载插件
    plugin_manager.discover_plugins()

    # 创建主界面
    app = MainWindow(root, config)

    # 加载插件
    plugin_manager.load_plugins(
        register_tool_cb=app.tool_tree.add_tool,
        register_category_cb=app.tool_tree.add_category
    )

    # 启动自动更新检查
    updater = AutoUpdater()
    updater.check_update()

    root.mainloop()
main()